//
// Created by Tony on 2024/1/14.
//

#ifndef PARSER_BINARY_EXPR_H
#define PARSER_BINARY_EXPR_H

#include "../../AstList.h"
#include "../../leaf/Operator.h"

namespace Parser {

class BinaryExpr final : public AstList {
    string nodeName;

public:
    explicit BinaryExpr(const vector<shared_ptr<Ast>>& children) : AstList(children) {
        nodeName = __func__;
    }

    bool isBinaryExpr() override { return true; }

    shared_ptr<Ast> left() { return children[0]; }
    shared_ptr<Operator> op() { return static_pointer_cast<Operator>(children[1]); }
    shared_ptr<Ast> right() { return children[2]; }

    int32_t accept(Compiler::Visitor* visitor) override;
};

} // namespace Parser

#endif // PARSER_BINARY_EXPR_H
